<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/rp/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <base href="<%=basePath%>">
    
    <title>导出数据</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	
	<script src="rp/scripts/boot.js" type="text/javascript"></script>
	<script src="rp/scripts/zclip/jquery.zclip.min.js"></script>
	
	<style type="text/css">
	   	.msg{margin-left:10px; color:green; border:1px solid #3c3; padding:4px 6px 6px 6px}
    </style>
	
  </head>
  
  <body class="body-p5">

	<span style="width: 100%; padding:4px 6px 6px 6px; border:1px solid #AAAAAA; margin-bottom: 5px; color: red;">将导出的结果数据复制，并将其粘贴至导入界面中即可完成数据导入</span>
  	
  	<textarea id="myTextarea" class="mini-textarea" value="" 
  		style="width: 100%; height: 250px; margin-bottom: 5px;"></textarea>
  		
  	<a id="copyButton" class="mini-button"><i class="fa fa-copy fa-lg"></i> 全选复制</a>
  	<a id="" class="mini-button" onclick="exportToFile()"><i class="fa fa-download fa-lg"></i> 导出到文件并下载</a>
  	
	<script type="text/javascript">
		var $text;
		var content;
		
		$(function(){
			mini.parse();
			$text = mini.get("myTextarea");
			
			$("#copyButton").zclip({
				path: "rp/scripts/zclip/ZeroClipboard.swf",
				beforeCopy: function(){
					
				},
				copy: function(){
		            return $text.getValue();
		        },
		        afterCopy: function(){
			        $("<span class='msg'/>").insertAfter($("#copyButton")).text("复制成功").fadeOut(2000);
			        //mini.alert("成功复制至剪切板");
		        }
			});
		});
		
		function initTextarea(_content){
			content = _content;
			$text.setValue(content);
		}

		function exportToFile(){
			rp_ajax("rp/system/common/writeTxt",{jsonData:content},function(result){
				if(result != "error"){
					window.location.href = "<%= basePath %>rp/system/common/exportFile?fileName="+result;
				}
			},true);
			
			return false;
		}
	</script>
  </body>
</html>
